import time
from selenium import webdriver
from selenium.webdriver import ActionChains
from pom.basepage.basepage import BasePage
from lib.share import css,xpath
from pom.page_teacher_op.login_page import TLoginPage


class THomePage(BasePage):
    loc_home = (css,'[href="#/home"]>li')
    loc_homework = (xpath,"//*[@class='main-menu']//li[2]")

    loc_homework_create = (xpath,
            "//*[@class='topbar-main']/*[@class='main-menu']/ul/*[5]/ul/*[2]//span")
    loc_homework_created = (xpath,
            "//*[@class='topbar-main']/*[@class='main-menu']/ul/*[5]/ul/*[3]//span")
    loc_homework_released = (xpath,
            "//*[@class='topbar-main']/*[@class='main-menu']/ul/*[5]/ul/*[4]//span")

    # next_step = {
    #     'homework':{
    #         'homework_create':'HomeWorkCreate',
    #         'homework_created':'HomeWorkCreated',
    #         'homework_released':'HomeWorkReleased',
    #     }
    # }

    def return_home(self):
        self.click(self.loc_home)

    def open_homework_create(self):
        self.move_to(self.loc_homework)
        self.move_to(self.loc_homework_create)
        self.click(self.loc_homework_create)

    def open_homework_created(self):
        self.move_to(self.loc_homework)
        self.move_to(self.loc_homework_created)
        self.click(self.loc_homework_created)

    def open_homework_released(self):
        self.move_to(self.loc_homework)
        self.move_to(self.loc_homework_released)
        self.click(self.loc_homework_released)


if __name__ == "__main__":
    driver = webdriver.Chrome()
    tloginpage = TLoginPage(driver)
    tloginpage.open(tloginpage.t_url)
    tloginpage.login()


    thomepage = THomePage(driver)
    # thomepage.open_homework_create()
    # thomepage.open_homework_created()
    thomepage.open_homework_released()
    time.sleep(5)
    driver.quit()


